<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>系统首页</title>

	<link rel="stylesheet" type="text/css" href="ui/style.css">	
    <link href="ui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="ui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="ui/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="ui/jquery.easyui.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="ui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="ui/common.js"></script>   
    <script type="text/javascript">       
       window.onload=function(){
           fixpng24();
       }
    </script>
   	<script type="text/javascript">
		function addTab(title, href,icon){
			var tt = $('#tt');
			if (tt.tabs('exists', title)){//如果tab已经存在,则选中并刷新该tab    	
		        tt.tabs('select', title);
		        refreshTab({tabTitle:title,url:href});
			} else {
		    	if (href){
			    	var content = '<iframe scrolling="no" frameborder="0"  src="'+href+'" style="width:100%;height:100%;"></iframe>';
		    	} else {
			    	var content = '未实现';
		    	}
		    	tt.tabs('add',{
			    	title:title,
			    	closable:true,
			    	content:content,
			    	iconCls:icon||'icon-default'
		    	});
			}
		}
		/**    
		 * 刷新tab
		 * @cfg 
		 *example: {tabTitle:'tabTitle',url:'refreshUrl'}
		 *如果tabTitle为空，则默认刷新当前选中的tab
		 *如果url为空，则默认以原来的url进行reload
		 */
		function refreshTab(cfg){
			var refresh_tab = cfg.tabTitle?$('#tt').tabs('getTab',cfg.tabTitle):$('#tt').tabs('getSelected');
			if(refresh_tab && refresh_tab.find('iframe').length > 0){
			var _refresh_ifram = refresh_tab.find('iframe')[0];
			var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;
			//_refresh_ifram.src = refresh_url;
			_refresh_ifram.contentWindow.location.href=refresh_url;
			}
		}
		
		$(function(){
			$.extend($.fn.validatebox.defaults.rules, {
			    equalTo: {
			        validator: function (value, param) {
			            return value == $(param[0]).val();
			        },
			        message: '两次输入的密码不一致'
			    }
			});
			$('#editPasswordForm input').each(function () {
				if ($(this).attr('required') || $(this).attr('validType'))
			    	$(this).validatebox();
				})
		});
		function openDialog(){
	    	$('#editPasswordDialog').dialog('open').dialog('setTitle','修改密码');  
		    //$('#addForm').form('reset');  
		    //$( "#editPasswordForm" )[ 0 ].reset();	    
	    }
	    function editPass(){	    	
	    	$('#editPasswordForm').form('submit',{  
		        url:"editUserPass.action",  
		        onSubmit: function(){  		        	
		            return $('#editPasswordForm').form('validate');
		        },  
		        success: function(result){
		        	//alert(result);  		            
		            var result = eval('('+result+')');  
		            if (result.success){ 
		            	$.messager.show({  
		                    title: '信息',  
		                    msg: result.message  
		                }); 
		            	$('#editPasswordDialog').dialog('close');      // close the dialog  
		           		$('#grid').datagrid('reload');    // reload the user data  
		            } else {  
		                $.messager.show({  
		                    title: '信息',  
		                    msg: result.message  
		                });
		            } 
		            $( "#editPasswordForm" )[ 0 ].reset();
		        } 
		    });
	    }
	    function resetForm(){
			$( "#editPasswordForm" )[ 0 ].reset();
		}
	</script>
   
  </head>
  
  <body>
    <div class="easyui-layout" style="width:100%;height:100%;">
		<div region="north" style="overflow:hidden;height:58px">
			<table border="0" cellpadding="0" cellspacing="0" width="100%"  
				height="60" background="ui/images/default.png">
				<tr >
					<td style="padding-left:15px"><img src="ui/images/logo.png" />
					</td>
					<td style="padding-right:5px">
					  <table width="100%"   border="0" cellpadding="0" cellspacing="3" class="banner">
					  	<tr align="right">
					      <td>你好，<s:property value="#session.user.name"/>&nbsp;&nbsp;今天是:<span id="rTime"></span></td>
					    </tr>
					    <tr align="right" valign="middle">
					    <td>
					      <div class="textAndImg"><img alt="退出系统" src="ui/images/exit.png"><a href="Logout.action" >退出系统</a></div>
					    </td>
					    </tr>
					  </table>
					</td>
				</tr>
			</table>
		</div>

		<div region="south" split="true" border="false" style="height:25px;background:#d2e0f2;TEXT-ALIGN:center;MARGIN-RIGHT:auto; MARGIN-LEFT:auto;">
			<span>版权所有 © 2011 盐城电信网络运行维护部</span>&nbsp;&nbsp;<a href="./ChangeLog.txt" target="_blank">version 2.0</a>
		</div>
		<div id="nav" region="west" split="true" iconCls="icon-tip" title="系统导航" style="width:180px;padding-left:5px;">
			<ul class="easyui-tree">
				<li iconCls="icon-people"><span><b>人员管理</b></span>
					<ul>
						<li iconCls="icon-li"><a href="javascript:void(0)" onclick="javascript:addTab('装维人员管理','personnelManagement.jsp','icon-people');return false;">人员信息管理</a></li>					
					</ul>
				</li>
				<li iconCls="icon-meter"><span><b>工具仪表管理</b></span>
					<ul>
						<li iconCls="icon-li"><a href="javascript:void(0)" onclick="javascript:addTab('FTTH工具仪表管理','meterManagement.jsp','icon-meter');return false;">FTTH工具仪表管理</a></li>					
					</ul>
				</li>
				<li iconCls="icon-gear"><span><b>系统设置</b></span>
					<ul>
						<li iconCls="icon-li"><a href="javascript:void(0)" onclick="javascript:openDialog();return false;">修改密码</a></li>
						<s:if test="%{#session.user.role=='全区'}">
							<li iconCls="icon-li"><a href="javascript:void(0)" onclick="javascript:addTab('用户管理','userManagement.jsp','icon-gear');return false;">用户管理</a></li>
						</s:if>						
					</ul>
				</li>
			</ul>
		</div>
		<div region="center" border="false">
			<div id="tt" class="easyui-tabs" fit="true" border="true">
				<div title="欢迎界面" href="welcome.jsp"></div>				
			</div>
			
		</div>
	</div>
	<div id="editPasswordDialog" class="easyui-dialog" style="width:450px;height:200px;padding:10px 10px;overflow:hidden;margin:auto"  
        closed="true" buttons="#dlg-buttons"> 
	    <form id="editPasswordForm" method="post">  
	    	<table width="400px" border="0"  cellpadding="0" cellspacing="0">
	    	  <tr>
	    	  	<td width="40%" height="30px"><div align="right"> <font color="red">*</font><label>原密码：</label></div></td>
	    	  	<td width="60%">
	    	  		<input type="password" id="oldPass" name="oldPass" style="width:60%" required="true"  >
	    	  	</td>
	    	  </tr>
	    	  <tr>
	    	  	<td width="40%" height="30px"><div align="right"> <font color="red">*</font><label>新密码：</label></div></td>
	    	  	<td width="60%">
	    	  		<input type="password" id="newPass" name="newPass" style="width:60%" required="true" >
	    	  	</td>
	    	  </tr>
	    	  <tr>
	    	  	<td width="40%" height="30px"><div align="right"> <font color="red">*</font><label>确认新密码：</label></div></td>
	    	  	<td width="60%">
	    	  		<input type="password" id="confirmPass" name="confirmPass" style="width:60%" required="true" validType="equalTo['#newPass']" />
	    	  	</td>
	    	  </tr>	
	    	</table>
	</div>  
	<div id="dlg-buttons">   
	    <a href="#" class="easyui-linkbutton" iconCls="icon-reload" onclick="javascript:resetForm();return false;">重置</a> 
	    <a href="javascript:void(0)" id="btnSave" class="easyui-linkbutton" iconCls="icon-ok" onclick="javascript:editPass();return false;">保存</a> 
	</div>
	<input type="hidden" name="uid" value="<s:property value="#session.user.id" />" />
	</form>  
  </body>
  <script type="text/javascript">
  	/**
	 * 显示系统时钟
	 */
	// TODO 此功能会一定程度浪费客户端系统资源
	
	function show(){
		var aa=new Date();
		bb=aa.getYear()+"-"+(aa.getMonth()+1)+"-"+aa.getDate()+"\r";
		var h = aa.getHours();
		h = h < 10 ? '0' + h : h;
		var m = aa.getMinutes();
		m = m < 10 ? '0' + m : m;
		var s = aa.getSeconds();
		s = s < 10 ? '0' + s : s;
		bb+=" 星期"+'日一二三四五六'.charAt(aa.getDay())+"\r"+h+":";
		bb+=m+":"+s;
		document.getElementById('rTime').innerHTML=bb;
		
	}
	setInterval("show()",1000);
  </script>
</html>
